#include <cstdio>
#include <cstring>

int a[ 7 ];

bool dfs( int sum )
{
    int i;
    if ( sum >= 31 ) return true;
    for ( i = 1; i <= 6; i++ )
        if ( a[ i ] && sum + i <= 31 )
        {
            a[ i ]--;
            if ( dfs( sum + i ) )
            {
                a[ i ]++;
                return false;
            }
            a[ i ]++;
        }
    return true;
}

int main( )
{
    int b[ 10 ], i, p, sum;
    char str[ 100 ];
    while ( scanf("%s", str) != EOF )
    {
        for ( i = 1; i <= 6; i++ ) a[ i ] = 4;
        sum = 0;
        p = 0;
        for ( i = 0; i < strlen( str ); i++ )
        {
            p ^= 1;
            a[ str[ i ] - '0' ]--;
            sum += str[ i ] - '0';
        }
        if ( dfs( sum ) )
            printf("%s %c\n", str, 'B' - p);
        else
            printf("%s %c\n", str, 'A' + p);
    }
    return 0;
}
